-- Copyright (c) 2024 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at:
--          http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.
local validate = require 'mc.validate'
local utils = require 'mc.utils'
local mdb = require 'mc.mdb'

local FirmwareActiveInfo = {}

---@class FirmwareActiveInfo.SystemId
---@field SystemId string
local TSystemId = {}
TSystemId.__index = TSystemId
TSystemId.group = {}

local function TSystemId_from_obj(obj)
    return setmetatable(obj, TSystemId)
end

function TSystemId.new(SystemId)
    return TSystemId_from_obj({SystemId = SystemId})
end
---@param obj FirmwareActiveInfo.SystemId
function TSystemId:init_from_obj(obj)
    self.SystemId = obj.SystemId
end

function TSystemId:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TSystemId.group)
end

TSystemId.from_obj = TSystemId_from_obj

TSystemId.proto_property = {'SystemId'}

TSystemId.default = {''}

TSystemId.struct = {{name = 'SystemId', is_array = false, struct = nil}}

function TSystemId:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'SystemId', self.SystemId, 'string', true, errs, need_convert)

    TSystemId:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TSystemId.proto_property, errs, need_convert)
    return self
end

function TSystemId:unpack(_)
    return self.SystemId
end

FirmwareActiveInfo.SystemId = TSystemId

---@class FirmwareActiveInfo.ActiveStatus
---@field ActiveStatus string
local TActiveStatus = {}
TActiveStatus.__index = TActiveStatus
TActiveStatus.group = {}

local function TActiveStatus_from_obj(obj)
    return setmetatable(obj, TActiveStatus)
end

function TActiveStatus.new(ActiveStatus)
    return TActiveStatus_from_obj({ActiveStatus = ActiveStatus})
end
---@param obj FirmwareActiveInfo.ActiveStatus
function TActiveStatus:init_from_obj(obj)
    self.ActiveStatus = obj.ActiveStatus
end

function TActiveStatus:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TActiveStatus.group)
end

TActiveStatus.from_obj = TActiveStatus_from_obj

TActiveStatus.proto_property = {'ActiveStatus'}

TActiveStatus.default = {''}

TActiveStatus.struct = {{name = 'ActiveStatus', is_array = false, struct = nil}}

function TActiveStatus:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'ActiveStatus', self.ActiveStatus, 'string', false, errs, need_convert)

    TActiveStatus:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TActiveStatus.proto_property, errs, need_convert)
    return self
end

function TActiveStatus:unpack(_)
    return self.ActiveStatus
end

FirmwareActiveInfo.ActiveStatus = TActiveStatus

---@class FirmwareActiveInfo.ActiveMode
---@field ActiveMode string
local TActiveMode = {}
TActiveMode.__index = TActiveMode
TActiveMode.group = {}

local function TActiveMode_from_obj(obj)
    return setmetatable(obj, TActiveMode)
end

function TActiveMode.new(ActiveMode)
    return TActiveMode_from_obj({ActiveMode = ActiveMode})
end
---@param obj FirmwareActiveInfo.ActiveMode
function TActiveMode:init_from_obj(obj)
    self.ActiveMode = obj.ActiveMode
end

function TActiveMode:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TActiveMode.group)
end

TActiveMode.from_obj = TActiveMode_from_obj

TActiveMode.proto_property = {'ActiveMode'}

TActiveMode.default = {''}

TActiveMode.struct = {{name = 'ActiveMode', is_array = false, struct = nil}}

function TActiveMode:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'ActiveMode', self.ActiveMode, 'string', true, errs, need_convert)

    TActiveMode:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TActiveMode.proto_property, errs, need_convert)
    return self
end

function TActiveMode:unpack(_)
    return self.ActiveMode
end

FirmwareActiveInfo.ActiveMode = TActiveMode

---@class FirmwareActiveInfo.ActiveCondition
---@field ActiveCondition string
local TActiveCondition = {}
TActiveCondition.__index = TActiveCondition
TActiveCondition.group = {}

local function TActiveCondition_from_obj(obj)
    return setmetatable(obj, TActiveCondition)
end

function TActiveCondition.new(ActiveCondition)
    return TActiveCondition_from_obj({ActiveCondition = ActiveCondition})
end
---@param obj FirmwareActiveInfo.ActiveCondition
function TActiveCondition:init_from_obj(obj)
    self.ActiveCondition = obj.ActiveCondition
end

function TActiveCondition:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TActiveCondition.group)
end

TActiveCondition.from_obj = TActiveCondition_from_obj

TActiveCondition.proto_property = {'ActiveCondition'}

TActiveCondition.default = {''}

TActiveCondition.struct = {{name = 'ActiveCondition', is_array = false, struct = nil}}

function TActiveCondition:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'ActiveCondition', self.ActiveCondition, 'string', true, errs, need_convert)

    TActiveCondition:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TActiveCondition.proto_property, errs, need_convert)
    return self
end

function TActiveCondition:unpack(_)
    return self.ActiveCondition
end

FirmwareActiveInfo.ActiveCondition = TActiveCondition

---@class FirmwareActiveInfo.FirmwareType
---@field FirmwareType string
local TFirmwareType = {}
TFirmwareType.__index = TFirmwareType
TFirmwareType.group = {}

local function TFirmwareType_from_obj(obj)
    return setmetatable(obj, TFirmwareType)
end

function TFirmwareType.new(FirmwareType)
    return TFirmwareType_from_obj({FirmwareType = FirmwareType})
end
---@param obj FirmwareActiveInfo.FirmwareType
function TFirmwareType:init_from_obj(obj)
    self.FirmwareType = obj.FirmwareType
end

function TFirmwareType:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TFirmwareType.group)
end

TFirmwareType.from_obj = TFirmwareType_from_obj

TFirmwareType.proto_property = {'FirmwareType'}

TFirmwareType.default = {''}

TFirmwareType.struct = {{name = 'FirmwareType', is_array = false, struct = nil}}

function TFirmwareType:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'FirmwareType', self.FirmwareType, 'string', true, errs, need_convert)

    TFirmwareType:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TFirmwareType.proto_property, errs, need_convert)
    return self
end

function TFirmwareType:unpack(_)
    return self.FirmwareType
end

FirmwareActiveInfo.FirmwareType = TFirmwareType

---@class FirmwareActiveInfo.FirmwareId
---@field FirmwareId string
local TFirmwareId = {}
TFirmwareId.__index = TFirmwareId
TFirmwareId.group = {}

local function TFirmwareId_from_obj(obj)
    return setmetatable(obj, TFirmwareId)
end

function TFirmwareId.new(FirmwareId)
    return TFirmwareId_from_obj({FirmwareId = FirmwareId})
end
---@param obj FirmwareActiveInfo.FirmwareId
function TFirmwareId:init_from_obj(obj)
    self.FirmwareId = obj.FirmwareId
end

function TFirmwareId:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TFirmwareId.group)
end

TFirmwareId.from_obj = TFirmwareId_from_obj

TFirmwareId.proto_property = {'FirmwareId'}

TFirmwareId.default = {''}

TFirmwareId.struct = {{name = 'FirmwareId', is_array = false, struct = nil}}

function TFirmwareId:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'FirmwareId', self.FirmwareId, 'string', true, errs, need_convert)

    TFirmwareId:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TFirmwareId.proto_property, errs, need_convert)
    return self
end

function TFirmwareId:unpack(_)
    return self.FirmwareId
end

FirmwareActiveInfo.FirmwareId = TFirmwareId

FirmwareActiveInfo.interface = mdb.register_interface('bmc.kepler.UpdateService.FirmwareActiveInfo', {
    FirmwareId = {'s', nil, true, nil, false},
    FirmwareType = {'s', nil, true, nil, false},
    ActiveCondition = {'s', nil, true, nil, false},
    ActiveMode = {'s', nil, true, nil, false},
    ActiveStatus = {'s', nil, false, nil, false},
    SystemId = {'s', nil, true, nil, false}
}, {}, {})

return FirmwareActiveInfo
